<?php /*a:1:{s:64:"D:\web\wwwroot\tp5.1\public/../app/admin/view\webconfig\add.html";i:1517708414;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>表单</title>
    <link rel="stylesheet" href="/static/frame/layui/css/layui.css">
    <link rel="stylesheet" href="/static/frame/static/css/style.css">
    <link rel="icon" href="/static/frame/static/image/code.png">
</head>
<body class="body">

<form class="layui-form" action="" method="post" id="addform">
    <div class="layui-form-item">
        <label class="layui-form-label">变量组id</label>
        <div class="layui-input-inline">
            <select name="groupid" lay-verify="required" lay-filter="webselect">
              <option value="1">网站基本配制</option>
              <option value="2">上传附件配制</option>
              <option value="3">邮件短信配制</option>
              <option value="4">支付配制</option>
              <option value="5">其它配制</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">变量类型</label>
            <div class="layui-input-inline">
            <select name="type" lay-verify="required" class="type-name" lay-filter="test">
              <option value="0">单行|input</option>
              <option value="1">多行|textarea</option>
              <option value="2">下拉|select</option>
              <option value="3">单选|radio</option>
              <option value="4">多选|checkbox</option>
            </select>
            </div>
        </div>
    </div>
<div id="typeval-config"></div>


    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">参数说明</label>
            <div class="layui-input-inline">
                <input type="type" name="name" lay-verify="name" autocomplete="off" placeholder="请输配置名称" class="layui-input">
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">变量名英文</label>
            <div class="layui-input-inline">
                <input type="type" name="varname" lay-verify="name" autocomplete="off" placeholder="请输配置字段名" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">请务必填写字段名 英文</div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">参数值</label>
        <div class="layui-input-inline">
            <input type="type" name="value" lay-verify="" autocomplete="off" placeholder="请输入配置值" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">系统参数值</div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">参数描述</label>
            <div class="layui-input-inline">
                <input type="type" name="info" lay-verify="" autocomplete="off" placeholder="请输入配置描述" class="layui-input">
            </div>
        </div>
    </div>
    
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<!-- 通用-970*90 -->
<script src="/static/frame/layui/layui.js" charset="utf-8"></script>
<script src="/static/admin/js/comm.js" charset="utf-8"></script>
<script>
    layui.use(['jquery', 'form', 'upload', 'laydate'], function(){
        var form = layui.form
                ,layer = layui.layer
                ,upload = layui.upload
                ,$ = layui.$; //重点处

        //自定义验证规则
        form.verify({
            title: function(value){
               // if(value.length < 2){
                    //return '标题至少得2个字符啊';
               // }
            }
        });

  //监听指定开关
  form.on('select(test)', function(data){
    if(data.value !=0 && data.value !=1){
        $('#typeval-config').html('<div class="layui-form-item">\
        <div class="layui-inline">\
                <label class="layui-form-label"><span style="color:#f00">类型参数</span></label>\
                <div class="layui-input-inline">\
                    <input type="type" name="typeval" lay-verify="typeval" autocomplete="off" placeholder="请输入样式类型参数" class="layui-input">\
                </div>\
                 <div class="layui-form-mid layui-word-aux">格式如:1|开启,0|关闭</div>\
            </div>\
        </div>');
    }else{
        $('#typeval-config').empty();
    }
    //console.log(data.value);
    // layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
    //   offset: '6px'
    // });
    // layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
  });


  //监听提交
        form.on('submit(demo1)', function(data){
            
                $.post('<?php echo url('admin/Webconfig/add'); ?>',$("#addform").serialize(),function(data){
                    if(data.code == 1){
                        layer.alert(data.msg, {
                            skin: 'layui-layer-molv' //样式类名
                              ,
                            closeBtn: 0
                          }, function() {
                            location.href = data.url;
                        });
                    }else{
                        layer.msg(data.msg);
                    }
                });
            return false;
        });


    });
</script>
</body>
</html>